#!/usr/bin/env python
# coding:utf-8
"""
@Version: V1.0
@Author: willson
@License: Apache Licence
@Contact: willson.wu@goertek.com
@Site: goertek.com
@Software: PyCharm
@File: api.py
@Time: 19-8-23 下午4:20
"""

import web

urls = (
    '/(.*)', 'hello'
)

app = web.application(urls, globals())


class hello:
    def __init__(self):
        # web.header('content-type', 'text/json')
        web.header('Access-Control-Allow-Origin', '*')
        # web.header('Access-Control-Allow-Methods', 'GET, POST')

    def GET(self, name):
        if not name:
            name = 'World'
        return {"name": name}

    def POST(self, name):
        # web.header("Access-Control-Allow-Origin", "*")
        print(web.data())
        return {"name": name, "data": web.data().decode("utf-8")}


if __name__ == "__main__":
    app.run()
